<?php echo $this->element('displayHeader'); ?>
<div class="toolbar">
    <div id="tLeft">
        <?php if ($page == 'inbox') : ?>
        <?php echo $this->element('toolbar', array('buttons' => array('add',
            array('edit' => array('text' => 'Reply', 'icon' => 'reply', 'action' => 'reply', 'params' => $this->data['Message']['id'])),
            array('delete' => array('model' => 'Message', 'title' => 'subject', 'action' => 'delete', 'params' => $this->data['Message']['id'] . '/' . $page)),
            array('back' => array('params' => $page))))); ?>
        <?php else : ?>
        <?php echo $this->element('toolbar', array('buttons' => array('add', 
            array('delete' => array('model' => 'Message', 'title' => 'subject', 'params' => $this->data['Message']['id'] . '/' . $page)), array('back' => array('params' => $page))))); ?>
        <?php endif; ?>
    </div>
    <div id="tRight"><?php echo $this->element('neighbors', array('model' => 'Message', 'title' => 'subject')); ?></div>
</div>

<fieldset>
    <table>
        <tbody>
            <tr>
                <td width="100px" class="top"><?php echo $form->label("MessageSent.receiver", $page == 'inbox'? 'Sender': "Send to") ?></td>
                <td>
                    <?php if ($page == 'inbox') : ?>
                        <?php if ($this->data['Message']['sender'] == ITS_PREFIX) {
                            echo $this->data['User']['name'] . ' @ ' . $this->requestAction('system_preferences/get/company_name');
                        } elseif ($this->data['Message']['sender'] == CUST_PREFIX) {
                            echo $this->data['User']['name'] . ' @ ' . $this->data['FromCustomer']['name'];
                        } elseif ($this->data['Message']['sender'] == SUPPLIER_PREFIX) {
                            echo $this->data['User']['name'] . ' @ ' . $this->data['FromSupplier']['name'];
                    } ?>
                    <?php else : ?>
                        <?php if ($this->data['Message']['receiver'] == ITS_PREFIX) {
                            echo $this->data['Message']['send_to'] . ' @ ' . $this->requestAction('system_preferences/get/company_name');
                        } elseif ($this->data['Message']['receiver'] == CUST_PREFIX) {
                            echo $this->data['Message']['send_to'] . ' @ ' . $this->data['ToCustomer']['name'];
                        } elseif ($this->data['Message']['receiver'] == SUPPLIER_PREFIX) {
                            echo $this->data['Message']['send_to'] . ' @ ' . $this->data['ToSupplier']['name'];
                    } ?>
                    <?php endif; ?>
                </td>
            </tr>
            <tr>
                <td><?php echo $form->label("MessageSent.subject", "Subject", array('class' => 'required')) ?></td>
                <td><?php echo $this->data['Message']['subject']; ?></td>
            </tr>
            <tr>
                <td><?php echo $form->label("MessageSent.sent_time", "Sent Time") ?></td>
                <td><?php echo $this->data['Message']['sent_time']; ?></td>
            </tr>
        </tbody>
    </table>
</fieldset>
<fieldset>
    <div class="messageBody"><?php echo $this->data['Message']['body']; ?></div>
</fieldset>
